﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAL;
using BL;

namespace QuanLyCHTrangSuc
{
    public partial class frmThongTinChiTietSanPham : Form
    {
        SanPhamDAL sp = null;
        public frmThongTinChiTietSanPham()
        {
            InitializeComponent();
        }

        public frmThongTinChiTietSanPham(SanPhamDAL aSp)
        {
            this.sp = aSp;
            InitializeComponent();
            gridThongSoKyThuat.Columns[0].DefaultCellStyle.Font = new Font("Arial", 8F, FontStyle.Bold);
            gridThongSoKyThuat.Columns[0].DefaultCellStyle.BackColor = SystemColors.ControlLight;
            gridThongSoKyThuat.Columns[1].DefaultCellStyle.BackColor = Color.WhiteSmoke;
            gridThongSoKyThuat.Columns[2].DefaultCellStyle.BackColor = Color.WhiteSmoke;
        }

        private void frmThongTinChiTietSanPham_Load(object sender, EventArgs e)
        {
            if (this.sp == null)
                return;
            this.pictureBox.Image = Image.FromFile(this.sp.HinhAnh);
            XL_DO_HOA.SetImage(this.pictureBox);
            this.txtMaSanPham.Text = this.sp.MaSanPham;
            this.txtTen.Text = this.sp.TenSanPham;
            this.txtGiaBan.Text = this.sp.GiaBan.ToString();
            NhaSanXuatBL nsxBL = new NhaSanXuatBL();
            List<NhaSanXuatDAL> dsNSX = nsxBL.LayDanhSachNhaSanXuat();
            this.txtNhaSanXuat.Text = dsNSX[0].TenNhaSanXuat;
            this.txtThongTinMoTa.Text = this.sp.ThongTinMoTa;
            
            XL_XML.ChuoiXML = this.sp.ThongSoKyThuat;
            XL_XML.DocTaiLieu();
            XL_XML.XuatRaLuoi("/THONGSOKYTHUAT/THONGSO", gridThongSoKyThuat);
        }

        private void pictureBox_Click(object sender, EventArgs e)
        {            
            frmHinhAnhMinhHoa frm = new frmHinhAnhMinhHoa(this.sp.HinhAnh);
            frm.ShowDialog();
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
